<?php

namespace app\api\controller\settings;

use app\api\controller\Controller;
use app\api\model\product\ProductBrandRelationModel;
use app\api\model\settings\DicModel;
use app\api\model\settings\FeedBackModel;
use app\Request;
use app\shop\model\product\BrandModel;

/**
 * 商品分类控制器
 */
class FeedBack extends Controller
{
    public function createData(Request $request)
    {
        $params = $request->param();
        $user = $this->getUser();
        $params['uid'] = $user['user_id'];
        FeedBackModel::createData($params);
        return $this->renderSuccess('操作成功');
    }

    public function createDataWeb(Request $request)
    {
    	$this->allowCrossDomain();
        $params = $request->param();
        $params['image'] = "";
        $params['content'] = "官网招商加盟反馈：".$params['content'];
        FeedBackModel::createData($params);
        return $this->renderSuccess('操作成功');
    }

    /**
     * @Exp    允许跨域请求
     */
    public function allowCrossDomain(){
            header("Access-Control-Allow-Origin:*");
            header("Access-Control-Allow-Methods:GET, POST, OPTIONS, DELETE");
            header("Access-Control-Allow-Headers:DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Accept-Language, Origin, Accept-Encoding,token,app-type");
            header("Access-Control-Max-Age:86400");
            //浏览器的option试探请求，要exit掉，不然你的业务会被执行两次
            if(request()->isOptions()) {#拦截预检测请求
                    return 200;
            }
            if (request()->isOptions()) {
                    exit();
            }
    }
}
